import { http } from "@/utils/http";
import { baseUrlApi, filerEmptyVal } from "../utils";

/** 订单列表查询 */
export const getStoreOrderList = (params?: object) => {
  return http.request<any>("get", baseUrlApi("/storeSuborderOrder/page"), {
    params: filerEmptyVal(params)
  });
};

/** 状态数量统计 */
export const getStoreOrderSum = (params?: object) => {
  return http.request<any>(
    "get",
    baseUrlApi("/storeSuborderOrder/state/quantity/statistics"),
    {
      params: filerEmptyVal(params)
    }
  );
};

/** 配货/发货出库商品明细 */
export const getDistributionDetail = (params?: object) => {
  return http.request<any>(
    "get",
    baseUrlApi("/storeSuborderOrder/distribution/detail"),
    {
      params: filerEmptyVal(params)
    }
  );
};

/** 商品明细预览 */
export const getGoodsDataDetail = (params?: object) => {
  return http.request<any>(
    "get",
    baseUrlApi("/storeSuborderOrder/goods/detail"),
    {
      params: filerEmptyVal(params)
    }
  );
};

/** 配货出库列表 */
export const getDistributionList = (params?: object) => {
  return http.request<any>(
    "get",
    baseUrlApi("/storeSuborderOrder/distributionList"),
    {
      params: filerEmptyVal(params)
    }
  );
};

/** 添加配货出库 */
export const addDistribution = (data?: object) => {
  return http.request<any>(
    "post",
    baseUrlApi("/storeSuborderOrder/distribution/add"),
    { data }
  );
};

/** 确认发货 */
export const confirmDelivery = (data?: object) => {
  return http.request<any>(
    "post",
    baseUrlApi("/storeSuborderOrder/confirm/delivery"),
    { data }
  );
};

/** 子订单状态修改 关闭/确认配货/完成 */
export const upStoreOrderStatus = (data?: any) => {
  return http.request<any>(
    "post",
    baseUrlApi(
      `/storeSuborderOrder/update/SuborderOrderStatus?suborderId=${data.suborderId}&suborderOrderStatus=${data.suborderOrderStatus}`
    ),
    { data }
  );
};

/** 发货详情(供应商) */
export const getSupplierDeliveryList = (params?: object) => {
  return http.request<any>(
    "get",
    baseUrlApi("/storeSuborderOrder/shipping/supplier/detail"),
    {
      params: filerEmptyVal(params)
    }
  );
};

/** 发货详情(仓库) */
export const getWareHouseDeliveryList = (params?: object) => {
  return http.request<any>(
    "get",
    baseUrlApi("/storeSuborderOrder/shipping/stash/detail"),
    {
      params: filerEmptyVal(params)
    }
  );
};

/** 发货作废(仓库) */
export const cancelWareHouseDelivery = (data?: object) => {
  return http.request<any>(
    "post",
    baseUrlApi("/storeSuborderOrder/void/delivery"),
    { data }
  );
};

/** 发货作废(供应商) */
export const cancelSupplierDelivery = (data?: object) => {
  return http.request<any>(
    "post",
    baseUrlApi("/storeSuborderOrder/void/supplier/delivery"),
    { data }
  );
};

/** 订单详情 */
export const getStoreOrderDetail = (params?: object) => {
  return http.request<any>(
    "get",
    baseUrlApi("/storeSuborderOrder/blanketOrder/detail"),
    { params }
  );
};

/** 修改订单 (废弃) */
export const upStoreOrder = (data?: object) => {
  return http.request<any>("post", baseUrlApi("/storeOrder/update"), { data });
};

/** 生成运单号 */
export const generateBillNo = (data?: object) => {
  return http.request<any>("post", baseUrlApi("/order/billNo/generate"), {
    data
  });
};

/** 销毁运单号 */
export const orderDestroyBillNo = (data?: object) => {
  return http.request<any>("post", baseUrlApi("/order/billNo/destroy"), {
    data
  });
};
